<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = ['小猪佩奇', '小猪乔治', '小羊苏西'];
        console.log(arr);
        console.log(arr[0]);
        console.log(arr[1]);
        console.log(arr[2]);
         arr[2] = '小猫凯迪';
         console.log(arr);

        console.log(arr[3]);   // undefined
        console.log(arr[-1]);  // undefined

        arr = [9, 5, 2, 7];
        arr.length = 6;
        console.log(arr);
        console.log(arr[4], arr[5]);

        arr = [];
        arr[2] = 10;
        console.log(arr);
        console.log(arr.length);

        arr = [9, 5, 2, 7, 3, 6, 8];
        var newArr = [];
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] % 2 != 0) {
                newArr.push(arr[i]);
            }
        }
        console.log(newArr);

        arr = [9, 5, 2, 7];
        // 第一个参数表示从下表为 2 的位置开始删除. 第二个参数表示要删除的元素个数是 1 个
        arr.splice(1, 2);
        console.log(arr);

        for(var i of arr){
            console.log(i);
        }

        // 结果 [9, 5, 7]
    </script>

length:返回长度
push(值):添加一个元素
splice(起始索引，数量)︰从起始索引开始，删除指定数量的元素

</body>
</html>